package com.company.project.demo.listener;

import com.company.project.demo.listener.event.DemoEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.event.TransactionPhase;
import org.springframework.transaction.event.TransactionalEventListener;

/**
 * @Description DemoListener
 * @Author zhongbo.yu
 * @Date 2021/12/28
 */
@Slf4j
@Component
public class DemoListener {

    /**
     * 事件处理器
     *
     * @param event
     */
    @Async(value = "demoEventListener")
    @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
    public void eventListener(DemoEvent event) {
        log.info("开始异步事件处理！event:{}", event);

    }
}
